package org.spring.blog.dao;

import org.spring.blog.pojo.Category;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

public interface CategoryDao extends JpaRepository<Category, String>, JpaSpecificationExecutor<Category> {

    Category findOneById(String categoryId);

    @Modifying
    @Query(nativeQuery = true, value = "update sob_blog_system.tb_categories set sob_blog_system.tb_categories.status = ?2 where sob_blog_system.tb_categories.id = ?1 order by sob_blog_system.tb_categories.create_time DESC")
    int updateCategoryStatus(String _categoryId, String _status);
}
